Skip to main content

Vietnamese ID Card Recognition

Requirements

  • The input image must have 4 clear angles or all main components of a Vietnamese ID card such as document title, contents, etc.
  • All information fields must be visible, readable, unmodified, not blurred.
  • The input image must contains only one document, as well as none of other objects with text on them.
  • The input image size does not exceed 5 MB and the minimum resolution is approximately 1280x720 to ensure the confident rate.
  • The ratio of Vietnamese ID card area must be at least 2/3 of the total image area.

Request

Request Url

POST https://api.fpt.ai/vision/vnm/id-fraudcheck

Request Headers

ParameterRequiredDefaultDescription
api_keyYesYour api key ( get from console.fpt.ai )

Request Body

In order to recognize an Vietnamese ID Card on the photo, a single image or image URL must be sent with the request by using one in 5 keys below:

ParameterRequiredTypeDescription
imageNo. Set either this parameter or image_url or image_base64.FileImage file
image_urlNo. Set either this parameter or image or image_base64.StringImage URL. Currently, HTTP/HTTPS URLs are supported
image_base64No. Set either this parameter or image or image_url.StringImage in the form of base64 string
image_list[]No. Set either this parameter or image or image_url or image_base64.StringList of image files
url_list[]No. Set either this parameter or image or image_url or image_base64.StringList of image URLs

Sample Request

Using image

curl --location --request POST 'https://api.fpt.ai/vision/vnm/id-fraudcheck' \
--header 'api_key: xxxxxxx' \
--form 'image=@/path/to/image' \
--form 'face=1'

Using URL

curl --location --request POST 'https://api.fpt.ai/vision/vnm/id-fraudcheck' \
--header 'api_key: xxxxxxx' \
--form 'image_url=link/to/image' \
--form 'face=1'

Using base64-string image

curl --location --request POST 'https://api.fpt.ai/vision/vnm/id-fraudcheck' \
--header 'api_key: xxxxxxx' \
--form 'image_base64=image/in/form/of/base64-string' \
--form 'face=1'

Using list of images

curl --location --request POST 'https://api.fpt.ai/vision/vnm/id-fraudcheck' \
--header 'api_key: xxxxxxx' \
--form 'image_list[]=@/path/to/image/of/front/side' \
--form 'image_list[]=@/path/to/image/of/back/side' \
--form 'face=1'

Response

JSON

{
"errorCode" : x,
"errorMessage" : "xxxx",
"data" : [xxxx]
}

The system is able to extract the information of Vietnamese ID card plus several checking results to make sure the integrity of the ID card image. The checking result includes fraud check before the OCR process has finished and post check after the OCR process has finished. Currently, all types of Vietnamese ID card are supported, including the old type, the new type, and the has-chip ID card:

  • old Vietnamese ID card front side
  • old Vietnamese ID card back side
  • new Vietnamese ID card front side.
  • new Vietnamese ID card back side.
  • has-chip Vietnamese ID card front side.
  • has-chip Vietnamese ID card back side.
  • new has-chip Vietnamese ID card front side.
  • new has-chip Vietnamese ID card back side.

Note:

  • old Vietnamese ID card: applies to the 9-digit ID card
  • new Vietnamese ID card: applies to the 12-digit ID card, no chip
  • has-chip Vietnamese ID card: applies to the 12-digit ID card, has chip, issued from Jan 23, 2021 to Jun 30, 2024.
  • new has-chip Vietnamese ID card: applies to the 12-digit ID card, has chip, issued from July 1, 2024.

After successfully sending the request, the system will return a json file that includes text information about the image quality using the format below:

  • errorCode: value is 0 if the request was successful with no error occurred
  • errorMessage: value is equal to empty string if the request was successful with no error occurred
  • data: includes all information about the content in the ID card and the checking results if the request succeeds without errors or return empty list [] if an error occurs. Also included with the information returned is the probability that indicates the reliability of the returned results. Besides, the data field also includes fraud-check results and post-check results (check the details below).

(The detail of the errors that might occure include both errorCode and errorMessage is described on Errors)

Data

{
"errorCode": 0,
"errorMessage": "",
"data": [
{
"id": "xxxxx",
"id_prob": "84.91",
"name": "xxxxx",
"name_prob": "91.73",
"dob": "xxxxx",
"dob_prob": "96.58",
"sex": "xxxxx",
"sex_prob": "99.78",
"nationality": "xxxxx",
"nationality_prob": "99.11",
"type_new": "xxxxx",
"doe": "xxxxx",
"doe_prob": "97.79",
"home": "xxxxx",
"home_prob": "92.71",
"address": "xxxxx",
"address_prob": "99.07",
"address_entities": {
"province": "xxxxx",
"district": "xxxxx",
"ward": "xxxxx",
"street": "xxxxx"
},
"QRcode": "ID number|Old ID number|Name|Date of birth|Gender|Address|Issue date",
"comparing_qrcode_result": {
"result": "Failed",
"code": "E01",
"message": "At least a field is not correct",
"different_fields": [
"id",
"name",
"dob",
"address"
]
},
"overall_score": "87.61",
"type": "new",
"checking_result": {
"recaptured_result": "0",
"recaptured_prob": "0.02",
"edited_result": "1",
"edited_prob": "0.97",
"corner_cut_result": "0",
"corner_cut_prob": [
"0.00",
"0.00",
"0.00",
"0.00"
],
"check_photocopied_result": "0",
"check_photocopied_prob": "0.27",
"check_title_result": "passed",
"check_title_prob": [
"0.67",
"0.49"
],
"check_emblem_result": "passed",
"check_emblem_prob": "0.76",
"check_fingerprint_result": "N/A",
"check_fingerprint_prob": [],
"check_stamp_result": "N/A",
"check_stamp_prob": [],
"check_embossed_stamp_result": "failed",
"check_embossed_stamp_prob": "0.00",
"check_border_result": "failed",
"check_border_prob": "0.71",
"low_score_result": [
"id",
]
},
"face": "/direct/link/to/face/image",
"face_base64": "/face/image/in/base64"
"cropped_idcard": "/direct/link/to/cropped/ID/card/image",
"cropped_idcard_base64": "/cropped/image/in/base64"
},
{
"post_check_result": {
"result": "Passed",
"code": "E00",
"message": ""
}
}
]
}

Information Extraction results

The old type Vietnamese ID card front side composes of 5 data fields:

FieldDescription
idID number
nameName
dobDate of birth
homeOriginal place
addressAddress

The old type Vietnamese ID card back side composes of 5 data fields:

FieldDescription
ethnicityEthnicity
religionReligion
featuresPersonal mark and disfigurement
issue_dateIssue date
issue_locIssue location

The new (no-chip)/has-chip type Vietnamese ID card (Căn cước công dân loại cũ và Căn cước công dân có chip) front side composes of 8 data fields:

FieldDescription
idID number
nameName
dobDate of birth
homeOriginal place
addressAddress
sexGender
nationality/ethnicityNationality/ Ethnicity
doeExpiry date

The new (no-chip)/has-chip type Vietnamese ID card back side composes of 2 or 3 data fields:

FieldDescription
featuresPersonal mark and disfigurement
issue_dateIssue date
mrzMRZ code (only in has-chip type)

The new has-chip type Vietnamese ID card front side composes of 5 data fields:

FieldDescription
idID number
nameName
dobDate of birth
sexGender
nationalityNationality

The new has-chip type Vietnamese ID card back side composes of 5 data fields:

FieldDescription
addressAddress
pobPlace of birth
issue_dateIssue date
doeExpiry date
mrzMRZ code (only in has-chip type)

Besides, there are 3 additional data fields, including:

FieldDescription
type

includes 8 types:

  • old: front side of old 9-digit ID card
  • old_back: back side of old 9-digit ID card
  • new: front side of new 12-digit ID card
  • new_back: back side of new 12-digit ID card
  • chip_front: front side of has-chip ID card
  • chip_back: back side of has-chip ID card
  • cc_front: front side of new has-chip ID card
  • cc_u6_front: front side of new has-chip ID card for under-6 children
  • cc_back: back side of new has-chip ID card
type_new

ID cards are separated into smaller classes which differentiate 2 types of new ID card; including 9 types:

  • cmnd_09_front: front side of old 9-digit ID card
  • old_back: back side of old 9-digit ID card
  • cmnd_12_front: front side of type-1 12-digit ID card
  • cccd_12_front: front side of type-2 12-digit ID card
  • new_back: back side of new 12-digit ID card
  • cccd_chip_front: front side of has-chip ID card
  • chip_back: back side of has-chip ID card
  • cc_front: front side of new has-chip ID card
  • cc_u6_front: front side of new has-chip ID card for under-6 children
  • cc_back: back side of new has-chip ID card
address_entities

the raw address will be standardized and separated into 4 parts:

  • province
  • district
  • ward
  • street
address_entity_with_code

the raw address will be standardized, separated into 4 parts and mapped with location codes as in this link location codes:

  • province|(province_code)
  • district|(district_code)
  • ward|(ward_code)
  • street|(ward_code)

Fraud-check results

The fraud-check results includes 16 fields of information:

FieldDescription
recaptured_resultChecking result of recapturing document from a LCD screen
edited_resultChecking result of the document that has been edited
corner_cut_resultChecking result of the document that has a cutting corner
check_photocopied_resultChecking result of the document that has been BW photocopied
check_emblem_resultChecking result of the front side of document that if its national emblem is covered/missing
check_headline_resultChecking result of the front side of document that if its headline is covered/missing
check_title_resultChecking result of the front side of document that if its title is covered/missing
check_fingerprint_resultChecking result of the document that if its fingerprints on the back side are covered/missing
check_stamp_resultChecking result of the document that if its stamp on the back side is covered/missing
check_QRcode_resultChecking result of the document that if it is has-chip ID card and its QRcode is covered/missing
check_chip_resultChecking result of the back side of document that if its chip is covered/missing
check_mrz_resultChecking result of the document that if it is has-chip ID card and its MRZ on the back side is covered/missing
check_covering_resultChecking result of that if there is any objects cover on the document
check_embossed_stamp_resultChecking result of the document that if its embossed stamp on the frontside is covered/missing
check_border_resultChecking result of the document that if its border is covered
low_score_resultList of fields contain low-score characters
check_watermark_resultChecking result of the image of document that if it has watermark or not
check_anti_counterfeiting_stamps_resultChecking result of the image of back side of document that if it has anti-counterfeiting stamps or not
check_face_resultChecking result of the image of front side of document that if it has a human portrait or not

The results of following criteria are in 1/0, in which 1 means yes and 0 means no (so good image should has all-0s results):

  • recaptured_result (applied for both sides): is "1" if "recaptured_prob" > 0.5, otherwise "0"
  • edited_result (applied for front side, back side "N/A"): is "1" if "edited_prob" > 0.6, otherwise "0"
  • corner_cut_result (applied for both sides): is "1" if one of "corner_cut_prob" > 0.5, otherwise "0"
  • check_photocopied_result (applied for both sides): is "1" if "check_photocopied_prob" >= 0.5, otherwise "0"

The results of following criteria are in passed/failed, so good image should has all-passed results:

  • check_emblem_result (applied for front side, back side "N/A"): is "passed" if "check_emblem_prob" >= 0.7, otherwise "failed"
  • check_headline_result (applied for front side, back side "N/A"): is "passed" if "check_headline_prob" >= 0.7, otherwise "failed"
  • check_title_result (applied for front side, back side "N/A"): is "passed" if "check_title_prob" >= 0.7, otherwise "failed"
  • check_fingerprint_result (applied for back side, front side "N/A"): is "passed" if both scores in "check_fingerprint_prob" >= 0.7, otherwise "failed"
  • check_stamp_result (applied for back side, front side "N/A"): is "passed" if "check_stamp_prob" >= 0.7, otherwise "failed"
  • check_QRcode_result (applied for front side of has-chip ID card, back side "N/A"): is "passed" if "check_QRcode_prob" >= 0.9, otherwise "failed"
  • check_chip_result (applied for back side of has-chip ID card, front side "N/A"): is "passed" if "check_chip_result" >= 0.7, otherwise "failed"
  • check_mrz_result (applied for back side of has-chip ID card, front side "N/A"): is "passed" if "check_mrz_prob" >= 0.75, otherwise "failed"
  • check_covering_result (experimental - applied for both sides): is "passed" if "check_covering_prob" < 0.5, otherwise "failed"
  • check_embossed_stamp_result (experimental - applied for front side of old ID card, back side "N/A"): is "passed" if "check_fingerprint_prob" >= 0.7, otherwise "failed"
  • check_border_result (experimental - applied for both sides of old type ID card): is "failed" if "check_border_result" >= 0.5, otherwise "passed"

The result of criterion low_score_result is the list of fields that contain low-score characters.

Comparing_qrcode_result

The "comparing_qrcode_result" to show the comparing result between QR code result and OCR result with several information (comparing result, error code, message, list of different fields):

"comparing_qrcode_result": {
"result": "Failed",
"code": "E01",
"message": "At least a field is not correct",
"different_fields": [
"name",
"address"
]
}

List of comparing_qrcode error messages:

CodeMesageDescription (Vietnamese)
E00PassedKiểm tra thành công
E01At least a field is not correctCó ít nhất một trường thông tin nào đó không chính xác
E02Undefined errorCó lỗi bất thường xảy ra
E03Cannot read QR CodeKhông đọc thành công QR Code

Post-check results

The post-check process will check the integrity in the information extracted from the document (1 side or 2 sides). For example: date of birth format, date of issuing format, ID number should match date of birth and address, etc. (check below for the details). If all the post-check tests are passed, the result will be:

{
"post_check_result": {
"result": "Passed",
"code": "E00",
"message": ""
}
}

In the case of not passing any tests, the result will be "Failed" and include the failing message. For example:

{
"post_check_result": {
"result": "Failed",
"code": "E08",
"message": "Gender code is not match"
}
}

Post-check process

alt text

List of post-check error messages:

CodeMesageDescription (Vietnamese)Description (English)
E00PassedKiểm tra thành côngThe OCR result is successfully passed the check
E01There is a NULL fieldCó một trường thông tin nào đó bị trốngThere is atleast a field of information is blank. Consider do the OCR again
E02ID format is not correctCấu trúc số ID không đúngThe structure of ID number is not correct. It is maybe the signal of bad OCR result or fraud
E03DoB format is not correctCấu trúc của ngày sinh không đúngThe structure of date of birth is not correct
E04DoB is later than todayNgày sinh không thể sau ngày hôm nayDate of birth is later than today. It is maybe the signal of bad OCR result or fraud
E05Current age cannot smaller than 14Tuổi hiện tại không thể dưới 14The old type of ID card cannot be issued to under-14 children. This is maybe the signal of bad OCR result or fraud
E07Year in DoB is not match with ID numberNăm sinh không khớp với số IDYear of birth should be match with ID number
E08Gender code is not matchMã giới tính không khớp với số IDGender code should be match with ID number
E09DoE format is not correctCấu trúc ngày hết hạn không đúngThe structure of date of expiration is not correct
E10ID card has been expiredGiấy tờ hết hạnThe document is expired
E11DoE cannot be "KHÔNG THỜI HẠN"Trường hợp chỉ gửi mặt trước và người mang giấy tờ dưới 58 tuổi vào thời điểm hiện tại thì ngày hết hạn không thể là "KHÔNG THỜI HẠN"If the document in submitted image is front side of ID card with chip and the document holder is currently under 58, then the expiration date cannot be "KHÔNG THỜI HẠN"
E12DoI format is not correctCấu trúc ngày cấp không đúngThe structure of date of issue is not correct
E13DoI is later than todayNgày cấp sau ngày hôm nayDate of issue is later than today. It is maybe the signal of bad OCR result or fraud
E14Reserved for later use
E15Please send images of front and back side of same type ID (old or new ID)Trường hợp gửi cả 2 mặt trong 1 request và đang gửi mặt trước + mặt sau của 2 loại giấy tờ khác nhauThe case that two images of two sides are submitted in the same request and they are not from the same type of document (old / new / chip)
E17Age at issue date cannot smaller than 14Trường hợp gửi cả 2 mặt trong 1 request và tuổi trên giấy tờ dưới 14 ở thời điểm cấpThe old type of ID card cannot be issued to under-14 children. This is maybe the signal of bad OCR result or fraud
E18DoE should be DoI + 15 yearsTrường hợp gửi cả 2 mặt trong 1 request và giấy tờ là Chứng minh nhân dân 12 số, ngày hết hạn là ngày cấp cộng thêm 15 nămThe case that two images of two sides are submitted in the same request and the document is 12-digit ID card, then the expiration date should be equal to the issue date plus 15 years
E19DoE should be birthday at 25 years oldTrường hợp gửi cả 2 mặt trong 1 request và nếu tuổi trên giấy tờ dưới 23 và trên 14 vào ngày cấp, thì ngày hết hạn phải là sinh nhật 25 tuổiThe case that two images of two sides are submitted in the same request and the document holder is under 23 and over 14 at the issue date, then the expiration date should be 25th birthday
E20DoE should be birthday at 40 years oldTrường hợp gửi cả 2 mặt trong 1 request và nếu tuổi trên giấy tờ dưới 38 và trên 23 vào ngày cấp, thì ngày hết hạn phải là sinh nhật 40 tuổiThe case that two images of two sides are submitted in the same request and the document holder is under 38 and over 23 at the issue date, then the expiration date should be 40th birthday
E21DoE should be birthday at 60 years oldTrường hợp gửi cả 2 mặt trong 1 request và nếu tuổi trên giấy tờ dưới 58 và trên 38 vào ngày cấp, thì ngày hết hạn phải là sinh nhật 60 tuổiThe case that two images of two sides are submitted in the same request and the document holder is under 58 and over 38 at the issue date, then the expiration date should be 60th birthday
E22DoE should be "KHÔNG THỜI HẠN"Trường hợp gửi cả 2 mặt trong 1 request và nếu tuổi trên giấy tờ trên 58 vào ngày cấp, thì ngày hết hạn phải là "KHÔNG THỜI HẠN"The case that two images of two sides are submitted in the same request and the document holder is over 58 at the issue date, then the expiration date should be "KHÔNG THỜI HẠN"
E30Front and back side are not from the same ID cardTrường hợp gửi cả 2 mặt trong 1 request và loại giấy tờ là Căn cước công dân gắn chip. Thông tin mặt sau không khớp với thông tin của mặt trướcThe case that two images of two sides are submitted in the same request and they are not from the same document
E31Issue location does not match issue dateÁp dụng cho trường hợp Căn cước công dân không chip: nơi cấp thay đổi theo từng thời kỳ phát hành.Applying for the case of no-chip ID, the IDs that were issued in different periods have different issue locations
E32Type of document does not match issue dateÁp dụng cho trường hợp Căn cước công dân có chip: CCCD có chip bắt đầu được phát hành từ ngày 23/01/2021. Với trường hợp Căn cước 2024: CC bắt đầu được phát hành từ ngày 01/07/2024.Applying for the case of has-chip ID, the date of issue on has-chip ID should be from 23/01/2021. Applying for the case of new has-chip ID (ID card 2024), the date of issue on new has-chip ID should be from 01/07/2024
E33DoE should be birthday at 14 years oldÁp dụng cho trường hợp Căn cước mới 2024 có chip: Ngày hết hạn phải là ngày sinh nhật 14 tuổi.Applying for the case of has-chip ID New 2024, Expiration date must be 14th birthday
E36Current age cannot smaller than 6Tuổi hiện tại không thể dưới 6The ID card 2024 type not for children cannot be issued to under-6 children. This is maybe the signal of bad OCR result or fraud
E37Age at issue date cannot smaller than 6Tuổi trên giấy tờ dưới 6 ở thời điểm cấp đối với Căn cước 2024The ID card 2024 type not for children cannot be issued to under-6 children. This is maybe the signal of bad OCR result or fraud
QR01QR code does not match OCR resultTrường hợp trong các giấy tờ gửi lên có bao gồm mặt trước của Căn cước công dân gắn chip hoặc mặt sau của Căn cước mới và cờ verify_qrcode=1. Kết quả QRcode đọc được không khớp với kết quả OCR The case that documents in the submitted images includes front side of ID card with chip or back side of new has-chip ID card and the flag verify_qrcode=1, then the QRcode result should be match with OCR result
QR02QR code format is not correctTrường hợp có cờ verify_qrcode=1. Kết quả QRcode đọc được không khớp với format QRcode nên có của loại giấy tờ The case that flag verify_qrcode=1, the QR code result does not match the expected format of the document’s QR code

Errors

The system uses the error codes as follows:

Error CodeMeaning
-1Undefined error -- Undefined error from system (this error should not happened in normal case)
0No error -- This is a successful call, no error
1Invalid Parameters or Values! -- Wrong parameter in the request (e.g. no key or image in the request body).
3Unable to find ID card in the image -- The system cannot find the Vietnamese ID card in the image or the image is of poor quality (too blur, too dark/bright).
5No URL in the request -- The request uses the image_url key but the value is left blank.
6Failed to open the URL! -- The request uses the image_url key but the system cannot open this URL.
7Invalid image file -- The uploaded file is not an image file.
8Bad data -- The uploaded image file is corrupted or the format is not supported.
9No string base64 in the request -- The request uses image_base64 key but the value is left blank.
10String base64 is not valid -- The request uses image_base64 key but the provided string is invalid.
11Quality check failed -- For the case that using params quality_check=1 and quality check result is failed.